/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "power")
@NamedQueries({
    @NamedQuery(name = "Power.findAll", query = "SELECT p FROM Power p"),
    @NamedQuery(name = "Power.findByPowerId", query = "SELECT p FROM Power p WHERE p.powerId = :powerId"),
    @NamedQuery(name = "Power.findByPowerDescrip", query = "SELECT p FROM Power p WHERE p.powerDescrip = :powerDescrip"),
    @NamedQuery(name = "Power.findByPowerLevel", query = "SELECT p FROM Power p WHERE p.powerLevel = :powerLevel"),
    @NamedQuery(name = "Power.findByPowerName", query = "SELECT p FROM Power p WHERE p.powerName = :powerName")})
public class Power implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "power_id")
    private Integer powerId;
    @Column(name = "power_descrip")
    private String powerDescrip;
    @Basic(optional = false)
    @Column(name = "power_level")
    private int powerLevel;
    @Basic(optional = false)
    @Column(name = "power_name")
    private String powerName;
    @JoinColumn(name = "depart_id", referencedColumnName = "depart_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Department department;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "power", fetch = FetchType.LAZY)
    private List<User> userList;

    public Power() {
    }

    public Power(Integer powerId) {
        this.powerId = powerId;
    }

    public Power(Integer powerId, int powerLevel, String powerName) {
        this.powerId = powerId;
        this.powerLevel = powerLevel;
        this.powerName = powerName;
    }

    public Integer getPowerId() {
        return powerId;
    }

    public void setPowerId(Integer powerId) {
        this.powerId = powerId;
    }

    public String getPowerDescrip() {
        return powerDescrip;
    }

    public void setPowerDescrip(String powerDescrip) {
        this.powerDescrip = powerDescrip;
    }

    public int getPowerLevel() {
        return powerLevel;
    }

    public void setPowerLevel(int powerLevel) {
        this.powerLevel = powerLevel;
    }

    public String getPowerName() {
        return powerName;
    }

    public void setPowerName(String powerName) {
        this.powerName = powerName;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (powerId != null ? powerId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Power)) {
            return false;
        }
        Power other = (Power) object;
        if ((this.powerId == null && other.powerId != null) || (this.powerId != null && !this.powerId.equals(other.powerId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.Power[powerId=" + powerId + "]";
    }

}
